package org.hl7.datatypes.r2.basic;

import java.util.Objects;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Embedded;
import org.hl7.datatypes.r2.flavors.ed.ED_TEXT;
import org.hl7.datatypes.r2.flavors.st.ST_NT;
import org.hl7.datatypes.r2.flavors.st.ST_SIMPLE;
import org.hl7.datatypes.r2.foundation.ANY;
import org.hl7.datatypes.r2.foundation.BL;
import org.hl7.datatypes.r2.foundation.DSET;
import org.hl7.datatypes.r2.foundation.SET;

/**
 * A reference to a concept defined in a code system
 *
 * @author Obama
 *
 */
@Embeddable
public class CD extends ANY {

    @Embedded
    @AttributeOverride(name = "stValue", column =
            @Column(name = "CODE"))
    private ST_SIMPLE code;
    @Embedded
    @AttributeOverride(name = "stValue", column =
            @Column(name = "CODE_SYSTEM"))
    private UID codeSystem;
    @Embedded
    @AttributeOverride(name = "stValue", column =
            @Column(name = "CODE_SYSTEM_NAME"))
    private ST_NT codeSystemName;
    @Embedded
    @AttributeOverride(name = "stValue", column =
            @Column(name = "CODE_SYSTEM_VERSION"))
    private ST_SIMPLE codeSystemVersion;
    @Embedded
    @AttributeOverride(name = "stValue", column =
            @Column(name = "VALUE_SET"))
    private UID valueSet;
    @Embedded
    @AttributeOverride(name = "stValue", column =
            @Column(name = "VALUE_SET_VERSION"))
    private ST_SIMPLE valueSetVersion;
    @Embedded
    private ST diplayName;
    @Embedded
    private ED_TEXT originalText;
    @Embedded
    private SET<CS> codingRationale;
    @Embedded
    private DSET<CD> translations;
    
    public CD() {
    }

    public ST_SIMPLE code() {
        return code;
    }

    public UID codeSystem() {
        return codeSystem;
    }

    public ST_NT codeSystemName() {
        return codeSystemName;
    }

    public ST_SIMPLE codeSystemVersion() {
        return codeSystemVersion;
    }

    public UID valueSet() {
        return valueSet;
    }

    public ST_SIMPLE valueSetVersion() {
        return valueSetVersion;
    }

    public ST displayName() {
        return diplayName;
    }

    public ED_TEXT originalText() {
        return originalText;
    }

    public SET<CS> codingRationale() {
        return codingRationale;
    }

    public DSET<CD> translation() {
        return translations;
    }

    public BL implies(CD x) {
        return null;
    }

    public ST_SIMPLE getCode() {
        return code;
    }

    public void setCode(ST_SIMPLE code) {
        this.code = code;
    }

    public UID getCodeSystem() {
        return codeSystem;
    }

    public void setCodeSystem(UID codeSystem) {
        this.codeSystem = codeSystem;
    }

    public ST_NT getCodeSystemName() {
        return codeSystemName;
    }

    public void setCodeSystemName(ST_NT codeSystemName) {
        this.codeSystemName = codeSystemName;
    }

    public ST_SIMPLE getCodeSystemVersion() {
        return codeSystemVersion;
    }

    public void setCodeSystemVersion(ST_SIMPLE codeSystemVersion) {
        this.codeSystemVersion = codeSystemVersion;
    }

    public UID getValueSet() {
        return valueSet;
    }

    public void setValueSet(UID valueSet) {
        this.valueSet = valueSet;
    }

    public ST_SIMPLE getValueSetVersion() {
        return valueSetVersion;
    }

    public void setValueSetVersion(ST_SIMPLE valueSetVersion) {
        this.valueSetVersion = valueSetVersion;
    }

    public ST getDiplayName() {
        return diplayName;
    }

    public void setDiplayName(ST diplayName) {
        this.diplayName = diplayName;
    }

    public ED_TEXT getOriginalText() {
        return originalText;
    }

    public void setOriginalText(ED_TEXT originalText) {
        this.originalText = originalText;
    }

    public SET<CS> getCodingRationale() {
        return codingRationale;
    }

    public void setCodingRationale(SET<CS> codingRationale) {
        this.codingRationale = codingRationale;
    }

    public DSET<CD> getTranslation() {
        return translations;
    }

    public void setTranslation(DSET<CD> translation) {
        this.translations = translation;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + Objects.hashCode(this.code);
        hash = 59 * hash + Objects.hashCode(this.codeSystem);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final CD other = (CD) obj;
        if (!Objects.equals(this.code, other.code)) {
            return false;
        }
        if (!Objects.equals(this.codeSystem, other.codeSystem)) {
            return false;
        }
        return true;
    }

    @Override
    public BL equal(ANY x) {
        return new BL(equals(x));
    }

    public CD source(){
        return null;
    }
}
